set memory 200m

use "C:\Users\mjoshi2\Desktop\Working Projects\Inclusive Institution Research\Inclusive Institutions and Survival of post-civil war TTD\with new casesv1.dta"
//use "C:\Users\mjoshi2\Desktop\Working Projects\Inclusive Institutions and Survival of post-civil war TTD\with new casesv1.dta"
//use "C:\Users\Madhav\Desktop\Dissertation Final\dissertation dataset and dofiles\with new casesv1.dta"
//W " Winning Coalition size"//
set more off

//Cold War =1 if year>1989//

gen coldwar = 1 if year>1989

replace coldwar = 0 if coldwar==.

//Generate Ethnic Fractionalization Square//
gen el_2 = el*el

//Generate log of battle death//
gen ln_battledeath = ln(battledeath)

//Generate ethnic conflict that secured territorial autonomy//
gen ethnic_autonomy = ethnic*cult_geo_auto

//Generate log of GDP Lag (lagged by one year)//
gen ln_gdplag = ln(gdplag)

//Generate log of population//
gen ln_pop = ln(pop)


gen neighbor_pull = polity2-neighboring_polity

//gen pr_president = pr_system*president
//gen pr_parliament = pr_system*parliament

gen joshi_institution = insti_joshi
replace joshi_institution=0 if  institution==0
replace joshi_institution=1 if  institution==1
replace joshi_institution=2 if  institution==2

//parliamentary and mixed system//
gen parliament=1 if joshi_institution==0
replace parliament=0 if parliament==.
gen mixed_system = 1 if joshi_institution==1
replace mixed_system=0 if mixed_system==.

//Institutional combination/interaction
gen pr_parliament = parliament*pr_system
gen el_parliament = el*parliament
gen el_PR = el*pr_system
gen el_pr_par =  pr_parliament*el


//drop  _st _d _origin _t _t0

drop if demo_survival!=1
gen demo_failure=demo_sur1
replace demo_failure=. if year==2005

//% of neighboring states in war
gen neigh_war_per = (no_neigh_conglict/neighbor)*100 

stset year, id(caseid) failure(demo_failure) origin(time year)

//Table 1 AIC BIC Information 



//Model 1
stcox pr_system parliament pr_parliament  mixed nego_s rebel_v pko 
estat ic

streg pr_system parliament pr_parliament  mixed nego_s rebel_v pko, dist(ll) cluster(ccode) time
estat ic

streg pr_system parliament pr_parliament  mixed nego_s rebel_v pko, dist(w) cluster(ccode) time
estat ic

streg pr_system parliament pr_parliament  mixed nego_s rebel_v pko, dist(ln) cluster(ccode) time
estat ic

streg pr_system parliament pr_parliament  mixed nego_s rebel_v pko, dist(e) cluster(ccode) time
estat ic

//Model 2
stcox pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle ethnic coldwar ln_gdp ln_pop 
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle ethnic coldwar ln_gdp ln_pop, dist(ll) cluster(ccode) time
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle ethnic coldwar ln_gdp ln_pop, dist(w) cluster(ccode) time
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle ethnic coldwar ln_gdp ln_pop, dist(ln) cluster(ccode) time
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle ethnic coldwar ln_gdp ln_pop, dist(e) cluster(ccode) time
estat ic

//Model 3
stcox pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp past 
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp past, dist(ll) cluster(ccode) time
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp past, dist(w) cluster(ccode) time
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp past, dist(ln) cluster(ccode) time
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp past, dist(e) cluster(ccode) time
estat ic

//Model 4
stcox pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp 
estat ic

streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp, dist(ll) cluster(ccode) time 
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp, dist(w) cluster(ccode) time 
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp, dist(ln) cluster(ccode) time 
estat ic
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp, dist(e) cluster(ccode) time 
estat ic


//Table 2
//Model 1
streg pr_system parliament pr_parliament  mixed nego_s rebel_v pko, dist(w) cluster(ccode) time

//Model 2
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle ethnic coldwar ln_gdp ln_pop, dist(w) cluster(ccode) time

//Model 3
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp past, dist(w) cluster(ccode) time

//Model 4
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp, dist(w) cluster(ccode) time

//Model 5
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp, dist(ln) cluster(ccode) time


//Graph Commands
streg pr_system parliament pr_parliament  nego_s rebel_v wardur ln_battle coldwar ln_gdp, dist(w) cluster(ccode) time
stcurve, hazard at1(pr_system = 1)  at2  (pr_system = 0)

//Combine graph
gr combine "C:\Users\mjoshi2\Desktop\Democratization 2012\pr system.gph" "C:\Users\mjoshi2\Desktop\Democratization 2012\parliament.gph"

